package com.gf.controller.order;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gf.bean.Orderr;

import com.gf.service.impl.OrderrServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/*
* 好像是废弃的servlet 没用因为我送的我下的订单就是所有的订单
* */

@WebServlet(name = "ShowmyordersServlet",urlPatterns = "/shoumyorders")
public class ShowmyordersServlet extends HttpServlet {
    static OrderrServiceImpl orderimpl = null;
    static {
        orderimpl=new OrderrServiceImpl();


    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        int userid =(int) request.getSession().getAttribute("userid");

        List<Orderr> orderrs = orderimpl.selectmyAllorders(userid);

        JSONObject backjson = new JSONObject();

        backjson.put("status", 200);
        backjson.put("data", orderrs);

        out.println(JSON.toJSON(backjson));
        out.flush();
        out.close();


    }
}
